import httpRequest from "@/util/httpRequest";
export default {
    DateFormat(date,fmt){
        var o = {
            "M+": date.getMonth() + 1, //月份 
            "d+": date.getDate(), //日 
            "H+": date.getHours(), //小时 
            "m+": date.getMinutes(), //分 
            "s+": date.getSeconds(), //秒 
            "q+": Math.floor((date.getMonth() + 3) / 3), //季度 
            "S": date.getMilliseconds() //毫秒 
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    },
    backPage(my){
        my.$router.go(-1);
    },
    getroleOptions(){
       httpRequest.post("角色集合 (用于选择框)", {}).then(res => {
            localStorage.setItem("roleOptions",JSON.stringify(res.data.list));
        });
    },
    getFirmNatureTypeOptions(){
       httpRequest.post("企业性质集合(用于选择框)", {}).then(res => {
            localStorage.setItem("FirmNatureTypeOptions",JSON.stringify(res.data.list));
        });
    },
    getTime(v,type){
        let time='';
        const date = type == 'new' ? new Date() : new Date(v);
        const year = date.getFullYear();
        var month = date.getMonth()+1;
        month = month>9 ? month :'0' + month;
        var day = date.getDate();
        day = day > 9 ? day:'0' + day;
        var hh = date.getHours();
        hh= hh>9 ? hh:'0'+hh;
        var mm = date.getMinutes();
        mm= mm>9 ? mm:'0'+mm;
        var ss = date.getSeconds();
        ss= ss>9 ? ss:'0'+ss;
        // var ms = date.getMilliseconds();
        if(type=='new'){
          time = year +'-' + month + '-' + day + ' ' + hh + ':' + mm + ':' + ss ;
        }else{
          time = year +'-' + month + '-' + day + '-' + hh + ':' + mm + ':' + ss  ;
        }
        return time;
      }
}